<!--
 * @Author: ReinerLau lk850593913@gmail.com
 * @Date: 2022-08-16 09:45:16
 * @LastEditors: ReinerLau lk850593913@gmail.com
 * @LastEditTime: 2023-02-09 13:46:33
 * @FilePath: \robot-management-web\src\views\robot\monitoring\map\components\BatteryIcon.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="relative h-5 flex items-center">
    <SvgIcon class="w-8 h-full" fill="#91EDFF" name="patroling-power"></SvgIcon>
    <div
      id="battery"
      class="absolute top-1/2 left-1 h-2.5 bg-[#91EDFF]"
      :style="{ width }"
    ></div>
  </div>
</template>

<script setup>
import { computed, toRefs } from "vue";

const props = defineProps({
  battery: {
    type: Number,
    default: 0,
  },
});
const { battery } = toRefs(props);
const width = computed(() => {
  if (battery.value > 100) return "1.4rem";
  return (battery.value / 100) * 1.4 + "rem";
});
</script>

<style lang="scss" scoped>
#battery {
  transform: translateY(-50%);
}
</style>
